package iss.team2.lams.web.controller;

import iss.team2.lams.model.LeaveApplication;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class EmployeeController 
{
	//Employee Navigation Controller
	@RequestMapping(value = "/employee", method = RequestMethod.GET)
	public ModelAndView empView()
	{
		return new ModelAndView("emp_leave");
	}
	
	@RequestMapping(value = "/employee/info", method = RequestMethod.GET)
	public ModelAndView empInfo()
	{
		return new ModelAndView("employeeInfo");
	}
	@RequestMapping(value = "/employee/request-attendance", method = RequestMethod.GET)
	public ModelAndView empRA()
	{
		return new ModelAndView("emp_requestAttendance");
	}
	@RequestMapping(value = "/employee/Leavehistory-Approved", method = RequestMethod.GET)
	public ModelAndView empRLH()
	{
		return new ModelAndView("emp_approvedLeaveHistory");
	}
	@RequestMapping(value ="/employee/Leavehistory-Appending", method = RequestMethod.GET)
	public ModelAndView empLHA()
	{
		return new ModelAndView("emp_appendingLeaveHistory");
	}
	@RequestMapping(value ="/employee/Leavehistory-Reject", method = RequestMethod.GET)
	public ModelAndView empLHR()
	{
		return new ModelAndView("emp_rejectLeaveHistory");
	}
	
	@RequestMapping(value="/employee/Leave-Form", method=RequestMethod.GET)
	public String addLeaveAppDisplay(@ModelAttribute("SpringWeb") LeaveApplication la, ModelMap model)
	{
		
		return("emp_leave");
	}
	//added by Mai
	@RequestMapping(value="/employee/Leave-Form/", method=RequestMethod.POST, params="save")
	public String addLeaveApp(@ModelAttribute("SpringWeb") LeaveApplication la, ModelMap model)
	{
		model.addAttribute("id", la.getLeaveId());
		model.addAttribute("leaveType", la.getLeaveCode());
		model.addAttribute("fromDate", la.getFromDate());
		model.addAttribute("toDate", la.getToDate());
		model.addAttribute("employeeComment", la.getEmployeeComment());
		return "TESTMAI";
		
	}
	//
	
	
	
	
	
	
	
	
	

}
